#pragma once


class  Size
{
public:
	Size() noexcept :wd(0), ht(0) {};
	Size(int w, int h)noexcept :wd(w), ht(h) {};

	//inline bool isNull() const noexcept;
	//inline bool isEmpty() const noexcept;
	inline bool isValid() const noexcept { { return wd >= 0 && ht >= 0; } };

	inline int width() const noexcept { return wd; };
	inline int height() const noexcept { return ht; };
	//inline void setWidth(int w) noexcept;
	//inline void setHeight(int h) noexcept;
	//void transpose() noexcept;
	//inline Size transposed() const noexcept;



	//inline Size expandedTo(const Size&) const noexcept;
	//inline Size boundedTo(const Size&) const noexcept;


	//inline int& rwidth() noexcept;
	//inline int& rheight() noexcept;

	//inline Size& operator+=(const Size&) noexcept;
	//inline Size& operator-=(const Size&) noexcept;
	//;

	//friend inline bool operator==(const Size&, const Size&) noexcept;
	//friend inline bool operator!=(const Size&, const Size&) noexcept;
	//friend inline const Size operator+(const Size&, const Size&) noexcept;
	//friend inline const Size operator-(const Size&, const Size&) noexcept;

private:
	int wd;
	int ht;
};




class  Rect
{
public:
	Rect() noexcept : x1(0), y1(0), x2(-1), y2(-1) {}
	//Rect(const QPoint& topleft, const QPoint& bottomright) noexcept;
	//Rect(const QPoint& topleft, const Size& size) noexcept;
	Rect(int left, int top, int width, int height) noexcept : x1(left), y1(top), x2(left + width - 1), y2(top + height - 1) {};

	//inline bool isNull() const noexcept;
	//inline bool isEmpty() const noexcept;
	//inline bool isValid() const noexcept;

	inline int left() const noexcept { return x1; };
	inline int top() const noexcept { return y1; };
	inline int right() const noexcept { return x2; }
	inline int bottom() const noexcept { return y2; }
	//Rect normalized() const noexcept;

	inline int x() const noexcept { return x1; }
	inline int y() const noexcept { return y1; }
	//inline void setLeft(int pos) noexcept;
	//inline void setTop(int pos) noexcept;
	//inline void setRight(int pos) noexcept;
	//inline void setBottom(int pos) noexcept;
	//inline void setX(int x) noexcept;
	//inline void setY(int y) noexcept;

	//inline void setTopLeft(const QPoint& p) noexcept;
	inline void setBottomRight(int x, int y) noexcept
	{
		x2 = x; y2 = y;
	}
	//inline void setTopRight(const QPoint& p) noexcept;
	//inline void setBottomLeft(const QPoint& p) noexcept;

	//inline QPoint topLeft() const noexcept;
	//inline QPoint bottomRight() const noexcept;
	//inline QPoint topRight() const noexcept;
	//inline QPoint bottomLeft() const noexcept;
	//inline QPoint center() const noexcept;

	//inline void moveLeft(int pos) noexcept;
	//inline void moveTop(int pos) noexcept;
	//inline void moveRight(int pos) noexcept;
	//inline void moveBottom(int pos) noexcept;
	//inline void moveTopLeft(const QPoint& p) noexcept;
	//inline void moveBottomRight(const QPoint& p) noexcept;
	//inline void moveTopRight(const QPoint& p) noexcept;
	//inline void moveBottomLeft(const QPoint& p) noexcept;
	//inline void moveCenter(const QPoint& p) noexcept;

	//inline void translate(int dx, int dy) noexcept;
	//inline void translate(const QPoint& p) noexcept;
	//inline Rect translated(int dx, int dy) const noexcept;
	//inline Rect translated(const QPoint& p) const noexcept;
	//inline Rect transposed() const noexcept;

	//inline void moveTo(int x, int t) noexcept;
	//inline void moveTo(const QPoint& p) noexcept;

	//inline void setRect(int x, int y, int w, int h) noexcept;
	//inline void getRect(int* x, int* y, int* w, int* h) const;

	//inline void setCoords(int x1, int y1, int x2, int y2) noexcept;
	//inline void getCoords(int* x1, int* y1, int* x2, int* y2) const;

	//inline void adjust(int x1, int y1, int x2, int y2) noexcept;
	//inline Rect adjusted(int x1, int y1, int x2, int y2) const noexcept;

	inline Size size() const noexcept { return Size(width(), height()); };
	inline int width() const noexcept { return  x2 - x1 + 1; };
	inline int height() const noexcept { return  y2 - y1 + 1; };
	//inline void setWidth(int w) noexcept;
	//inline void setHeight(int h) noexcept;
	//inline void setSize(const Size& s) noexcept;

	//Rect operator|(const Rect& r) const noexcept;
	//Rect operator&(const Rect& r) const noexcept;
	//inline Rect& operator|=(const Rect& r) noexcept;
	//inline Rect& operator&=(const Rect& r) noexcept;

	//bool contains(const Rect& r, bool proper = false) const noexcept;
	//bool contains(const QPoint& p, bool proper = false) const noexcept;
	inline bool contains(int x, int y) const noexcept {

		int l, r;
		if (x2 < x1 - 1) {
			l = x2;
			r = x1;
		}
		else {
			l = x1;
			r = x2;
		}

		if (x < l || x > r)
			return false;

		int t, b;
		if (y2 < y1 - 1) {
			t = y2;
			b = y1;
		}
		else {
			t = y1;
			b = y2;
		}

		if (y < t || y > b)
			return false;

		return true;

	};
	//inline bool contains(int x, int y, bool proper) const noexcept;
	//inline Rect united(const Rect& other) const noexcept;
	//inline Rect intersected(const Rect& other) const noexcept;
	//bool intersects(const Rect& r) const noexcept;

	//inline Rect marginsAdded(const QMargins& margins) const noexcept;
	//inline Rect marginsRemoved(const QMargins& margins) const noexcept;
	//inline Rect& operator+=(const QMargins& margins) noexcept;
	//inline Rect& operator-=(const QMargins& margins) noexcept;



	friend  inline bool operator==(const Rect&, const Rect&) noexcept;
	friend  inline bool operator!=(const Rect&, const Rect&) noexcept;

private:
	int x1;
	int y1;
	int x2;
	int y2;
};